<template>
  <div class="add-schedule content-bg">
    <el-form ref="form"
             :model="form"
             :rules="rules"
             label-width="80px">
      <el-form-item label="日期" prop="date">
        <el-date-picker type="date" placeholder="选择日期" v-model="form.date" style="width: 100%;"></el-date-picker>
      </el-form-item>
      <el-form-item label="日程" prop="schedule">
        <el-input type="textarea"  v-model="form.content"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary"
                   @click="onSubmit">提交</el-button>
        <el-button @click="goBack">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script lang="js">
import axios from "axios";

export default {
    data(){
      return{
        form: {},
        rules: {
          date: [
            { required: true, message: '请输入日期', trigger: 'blur' }
          ],
          content:[
          { required: true, message: '请输入日程', trigger: 'blur' },
            { min: 5, max: 30, message: '长度在 5 到 30个字符', trigger: 'blur' }
          ]
        },
      }
    },
    methods: {
      onSubmit(){
        axios.post("/schedule",this.form).then((res)=>{
          console.log(this.form)
          if (res.data.code === 1){
            this.$message.success(res.data.data)
          }else {
            this.$message.error(res.data.msg)
          }
        }).finally(this.form = {})
      },
      goBack(){
        //
      }
    }

}
</script>
<style lang="scss" scoped>
</style>
